package com.wondersgroup.framework.sample.component.grid.action;

import com.wondersgroup.framework.core.web.struts2.action.BaseAjaxAction;
import com.wondersgroup.framework.core.web.vo.VOUtils;
import com.wondersgroup.framework.core5.model.vo.ValueObject;
import com.wondersgroup.framework.sample.component.grid.vo.GroupVO;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class GroupGridAction extends BaseAjaxAction
{
  private GroupVO groupVO;
  private List<GroupVO> groupData;

  public GroupGridAction()
  {
    this.groupVO = new GroupVO();

    this.groupData = new ArrayList();
  }

  protected String operate() {
    this.groupData = getGroupData();
    String json = VOUtils.getJsonDataFromCollection(this.groupData);
    return json;
  }

  public List<GroupVO> getGroupData() {
    return ((List)getServletRequest().getSession().getServletContext().getAttribute("groupList"));
  }

  public void setGroupData(List<GroupVO> groupData) {
    getServletRequest().getSession().getServletContext().setAttribute("groupList", groupData);
  }

  public ValueObject getValueObject()
  {
    return this.groupVO;
  }
}